/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Barang.java
 *
 * Created on 30 Nov 10, 10:58:09
 */
package view;

import controller.ControllerBarangMasuk;
import java.awt.Color;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.border.BevelBorder;
import utility.TableGenerator;

/**
 *
 * @author Mirza
 */
public class BarangMasuk extends javax.swing.JPanel {

    private int selectedIndex = 0;
    private boolean tambahBarangMasuk = false;
    private GradientPaint paint;
    private boolean pilihBarang;
    private boolean pilihPegawai;
    private boolean pilihSuplier;

    /** Creates new form Barang */
    public BarangMasuk() {
        initComponents();
        refreshTabel();
        setActiveInput(false);
        setOpaque(false);
        setBorder(new BevelBorder(BevelBorder.LOWERED));
    }

    @Override
    protected void paintComponent(Graphics g) {
        Graphics2D gd = (Graphics2D) g.create();
        paint = new GradientPaint(getWidth(), 0, Color.BLUE, 0, 0, Color.WHITE);
        gd.setPaint(paint);
        gd.fillRect(0, 0, getWidth(), getHeight());
        gd.dispose();
        super.paintComponent(g);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jComboBoxJenisPencarian = new javax.swing.JComboBox();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jTextFieldDiterimaOleh = new javax.swing.JTextField();
        jTextFieldKodeBarang = new javax.swing.JTextField();
        jTextFieldJumlah = new javax.swing.JTextField();
        jButtonBatal = new javax.swing.JButton();
        jButtonSimpan = new javax.swing.JButton();
        jButtonHapus = new javax.swing.JButton();
        jButtonUbah = new javax.swing.JButton();
        jButtonTambah = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTableBarangMasuk = new javax.swing.JTable();
        jLabel4 = new javax.swing.JLabel();
        jTextFieldDiterimaDari = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        jTextFieldTanggalMasuk = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        jTextFieldKeterangan = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jTextFieldPencarian = new javax.swing.JTextField();

        jComboBoxJenisPencarian.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Kode Barang", "Nama Barang", "Jumlah", "Tanggal Masuk", "Nip", "Diterima Oleh", "Kode Suplier", "Diterima Dari", "Keterangan" }));
        jComboBoxJenisPencarian.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBoxJenisPencarianActionPerformed(evt);
            }
        });

        jLabel1.setFont(new java.awt.Font("Verdana", 1, 12));
        jLabel1.setText("Diterima Oleh");

        jLabel2.setFont(new java.awt.Font("Verdana", 1, 12));
        jLabel2.setText("Kode Barang");

        jLabel3.setFont(new java.awt.Font("Verdana", 1, 12));
        jLabel3.setText("Jumlah");

        jTextFieldDiterimaOleh.setEditable(false);
        jTextFieldDiterimaOleh.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                jTextFieldDiterimaOlehFocusGained(evt);
            }
        });

        jTextFieldKodeBarang.setEditable(false);
        jTextFieldKodeBarang.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldKodeBarangActionPerformed(evt);
            }
        });
        jTextFieldKodeBarang.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                jTextFieldKodeBarangFocusGained(evt);
            }
        });

        jButtonBatal.setText("Batal");
        jButtonBatal.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonBatalActionPerformed(evt);
            }
        });

        jButtonSimpan.setText("Simpan");
        jButtonSimpan.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonSimpanActionPerformed(evt);
            }
        });

        jButtonHapus.setText("Hapus");
        jButtonHapus.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonHapusActionPerformed(evt);
            }
        });

        jButtonUbah.setText("Ubah");
        jButtonUbah.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonUbahActionPerformed(evt);
            }
        });

        jButtonTambah.setText("Tambah");
        jButtonTambah.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonTambahActionPerformed(evt);
            }
        });

        jTableBarangMasuk.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null, null, null, null, null, null}
            },
            new String [] {
                "KODE BARANG MASUK", "KODE BARANG", "NAMA BARANG", "JUMLAH", "TANGGAL MASUK", "NIP", "DITERIMA OLEH", "KODE SUPLIER", "DITERIMA DARI", "KETERANGAN"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false, false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTableBarangMasuk.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTableBarangMasukMouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                jTableBarangMasukMouseEntered(evt);
            }
        });
        jScrollPane1.setViewportView(jTableBarangMasuk);

        jLabel4.setFont(new java.awt.Font("Verdana", 1, 12));
        jLabel4.setText("Diterima Dari");

        jTextFieldDiterimaDari.setEditable(false);
        jTextFieldDiterimaDari.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                jTextFieldDiterimaDariFocusGained(evt);
            }
        });

        jLabel5.setFont(new java.awt.Font("Verdana", 1, 12));
        jLabel5.setText("Tanggal masuk");

        jTextFieldTanggalMasuk.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldTanggalMasukActionPerformed(evt);
            }
        });

        jLabel6.setFont(new java.awt.Font("Verdana", 1, 12));
        jLabel6.setText("Keterangan");

        jLabel7.setFont(new java.awt.Font("Verdana", 1, 12));
        jLabel7.setText("(dd/mm/yyyy)");

        jTextFieldPencarian.setText("search");
        jTextFieldPencarian.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldPencarianActionPerformed(evt);
            }
        });
        jTextFieldPencarian.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                jTextFieldPencarianFocusGained(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 953, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jButtonTambah)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButtonUbah, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButtonHapus, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(148, 148, 148)
                        .addComponent(jButtonSimpan, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jLabel3)
                    .addComponent(jLabel6)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                .addComponent(jLabel4)
                                .addGap(59, 59, 59)
                                .addComponent(jTextFieldDiterimaDari))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                .addGap(148, 148, 148)
                                .addComponent(jTextFieldJumlah))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                .addComponent(jLabel2)
                                .addGap(64, 64, 64)
                                .addComponent(jTextFieldKodeBarang, javax.swing.GroupLayout.PREFERRED_SIZE, 196, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(49, 49, 49)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jTextFieldTanggalMasuk, javax.swing.GroupLayout.DEFAULT_SIZE, 196, Short.MAX_VALUE)
                                    .addComponent(jTextFieldKeterangan)))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(jButtonBatal, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                    .addComponent(jLabel1)
                                    .addGap(56, 56, 56)
                                    .addComponent(jTextFieldDiterimaOleh, javax.swing.GroupLayout.PREFERRED_SIZE, 194, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel7))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jComboBoxJenisPencarian, javax.swing.GroupLayout.PREFERRED_SIZE, 168, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextFieldPencarian, javax.swing.GroupLayout.PREFERRED_SIZE, 187, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jComboBoxJenisPencarian, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTextFieldPencarian, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 283, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButtonHapus)
                    .addComponent(jButtonUbah)
                    .addComponent(jButtonTambah))
                .addGap(25, 25, 25)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jTextFieldKodeBarang, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextFieldJumlah, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3))
                .addGap(8, 8, 8)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel6)
                    .addComponent(jTextFieldKeterangan, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel5)
                            .addComponent(jTextFieldTanggalMasuk, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel4)
                            .addComponent(jTextFieldDiterimaDari, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1)
                            .addComponent(jTextFieldDiterimaOleh, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jButtonSimpan)
                            .addComponent(jButtonBatal)))
                    .addComponent(jLabel7))
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void refreshTabel() {
        try {
            String[] listField = {"KODE_BARANG_MASUK", "KODE_BARANG", "NAMA_BARANG", "JUMLAH", "TANGGAL_MASUK", "NIP", "DITERIMA_OLEH", "KODE_SUPLIER", "DITERIMA_DARI", "KETERANGAN"};
            TableGenerator.generateTable(jTableBarangMasuk, ControllerBarangMasuk.searchBarangMasuk(""), listField);

        } catch (SQLException ex) {
            Logger.getLogger(Suplier.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    private void setActiveInput(boolean status) {
        jButtonTambah.setEnabled(!status);
        jButtonUbah.setEnabled(!status);
        jButtonHapus.setEnabled(!status);
        jTextFieldKodeBarang.setEnabled(status);
        jTextFieldJumlah.setEnabled(status);
        jTextFieldKeterangan.setEnabled(status);
        jTextFieldTanggalMasuk.setEnabled(status);
        jTextFieldDiterimaDari.setEnabled(status);
        jTextFieldDiterimaOleh.setEnabled(status);
        jButtonSimpan.setEnabled(status);
        jButtonBatal.setEnabled(status);
    }

    private void kosongkanInput() {
        jTextFieldKodeBarang.setText("");
        jTextFieldJumlah.setText("");
        jTextFieldKeterangan.setText("");
        jTextFieldTanggalMasuk.setText("");
        jTextFieldDiterimaDari.setText("");
        jTextFieldDiterimaOleh.setText("");
        pilihBarang = true;
        pilihPegawai = true;
        pilihSuplier = true;
    }

    private void tampilkanDataTabelKeInput() {
        jTextFieldKodeBarang.setText((String) jTableBarangMasuk.getValueAt(selectedIndex, 1));
        jTextFieldJumlah.setText((String) jTableBarangMasuk.getValueAt(selectedIndex, 3));
        jTextFieldKeterangan.setText((String) jTableBarangMasuk.getValueAt(selectedIndex, 9));
        jTextFieldTanggalMasuk.setText((String) jTableBarangMasuk.getValueAt(selectedIndex, 4));
        jTextFieldDiterimaDari.setText((String) jTableBarangMasuk.getValueAt(selectedIndex, 5));
        jTextFieldDiterimaOleh.setText((String) jTableBarangMasuk.getValueAt(selectedIndex, 7));
    }

    private void jButtonHapusActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonHapusActionPerformed
        // TODO add your handling code here:
        int a = JOptionPane.showConfirmDialog(this, "Apakah anda yakin akan menghapus data ?");
        if (a == 0) {
            ControllerBarangMasuk.deleteFromBarangMasuk((String) jTableBarangMasuk.getValueAt(selectedIndex, 0));
            refreshTabel();
        }
    }//GEN-LAST:event_jButtonHapusActionPerformed

    private void jTextFieldKodeBarangActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldKodeBarangActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_jTextFieldKodeBarangActionPerformed

    private void jButtonBatalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonBatalActionPerformed
        // TODO add your handling code here:
        kosongkanInput();
        tambahBarangMasuk = true;
        setActiveInput(false);
    }//GEN-LAST:event_jButtonBatalActionPerformed

    private void jComboBoxJenisPencarianActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxJenisPencarianActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jComboBoxJenisPencarianActionPerformed

    private void jButtonTambahActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonTambahActionPerformed
        // TODO add your handling code here:
        kosongkanInput();
        tambahBarangMasuk = true;
        setActiveInput(true);
    }//GEN-LAST:event_jButtonTambahActionPerformed

    private void jButtonUbahActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonUbahActionPerformed
        // TODO add your handling code here:
        tambahBarangMasuk = false;
        setActiveInput(true);
    }//GEN-LAST:event_jButtonUbahActionPerformed

    private void jButtonSimpanActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSimpanActionPerformed
        // TODO add your handling code here:
        String tanggal = jTextFieldTanggalMasuk.getText();
        tanggal = tanggal.substring(6) + "-" + tanggal.substring(3, 5) + "-" + tanggal.substring(0, 2);
        jTextFieldTanggalMasuk.setText(tanggal);
        if (tambahBarangMasuk) {
            if (ControllerBarangMasuk.insertIntoBarangMasuk(jTextFieldKodeBarang.getText(), jTextFieldJumlah.getText(), jTextFieldKeterangan.getText(), jTextFieldTanggalMasuk.getText(), jTextFieldDiterimaDari.getText(), jTextFieldDiterimaOleh.getText())) {
                JOptionPane.showMessageDialog(this, "Data Berhasil dimasukkan");
                refreshTabel();
            }
        } else {
            if (ControllerBarangMasuk.updateBarangMasuk((String) jTableBarangMasuk.getValueAt(selectedIndex, 0), jTextFieldKodeBarang.getText(), jTextFieldJumlah.getText(), jTextFieldKeterangan.getText(), jTextFieldTanggalMasuk.getText(), jTextFieldDiterimaDari.getText(), jTextFieldDiterimaOleh.getText())) {
                JOptionPane.showMessageDialog(this, "Data Berhasil diubah");
                refreshTabel();
            }
        }
        setActiveInput(false);
    }//GEN-LAST:event_jButtonSimpanActionPerformed

    private void jTableBarangMasukMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTableBarangMasukMouseClicked
        selectedIndex = jTableBarangMasuk.getSelectedRow();
        tampilkanDataTabelKeInput();
        tambahBarangMasuk = false;
    }//GEN-LAST:event_jTableBarangMasukMouseClicked

    private void jTextFieldTanggalMasukActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldTanggalMasukActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextFieldTanggalMasukActionPerformed

    private void jTextFieldKodeBarangFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextFieldKodeBarangFocusGained
        if (pilihBarang) {
            JOptionPane.showMessageDialog(this, "Silahkan memilih barang");
            ViewUtama.formBarang = new FormBarang();
            ViewUtama.formBarang.setVisible(true);
            pilihBarang = false;
        } else {
            if (ViewUtama.kodeBarang != null) {
                jTextFieldKodeBarang.setText(ViewUtama.kodeBarang);
            }
        }
    }//GEN-LAST:event_jTextFieldKodeBarangFocusGained

    private void jTextFieldDiterimaOlehFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextFieldDiterimaOlehFocusGained
        if (pilihPegawai) {
            JOptionPane.showMessageDialog(this, "Silahkan memilih pegawai");
            ViewUtama.formPegawai = new FormPegawai();
            ViewUtama.formPegawai.setVisible(true);
            pilihPegawai = false;
        } else {
            if (ViewUtama.nip != null) {
                jTextFieldDiterimaOleh.setText(ViewUtama.nip);
            }
        }
    }//GEN-LAST:event_jTextFieldDiterimaOlehFocusGained

    private void jTextFieldDiterimaDariFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextFieldDiterimaDariFocusGained
        if (pilihSuplier) {
            JOptionPane.showMessageDialog(this, "Silahkan memilih Suplier");
            ViewUtama.formSuplier = new FormSuplier();
            ViewUtama.formSuplier.setVisible(true);
            pilihSuplier = false;
        } else {
            if (ViewUtama.kodeSuplier != null) {
                jTextFieldDiterimaDari.setText(ViewUtama.kodeSuplier);
            }
        }
    }//GEN-LAST:event_jTextFieldDiterimaDariFocusGained

    private void jTextFieldPencarianActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldPencarianActionPerformed
        String[] listField = {"KODE_BARANG_MASUK", "KODE_BARANG", "NAMA_BARANG", "JUMLAH", "TANGGAL_MASUK", "NIP", "DITERIMA_OLEH", "KODE_SUPLIER", "DITERIMA_DARI", "KETERANGAN"};
        String filter = "";
        if (!jTextFieldPencarian.getText().equals("")) {
            filter = "where " + jComboBoxJenisPencarian.getItemAt(jComboBoxJenisPencarian.getSelectedIndex()).toString().replaceAll(" ", "_") + " like '%" + jTextFieldPencarian.getText() + "%'";
        }
        try {
            TableGenerator.generateTable(jTableBarangMasuk, ControllerBarangMasuk.searchBarangMasuk(filter), listField);
        } catch (SQLException ex) {
            Logger.getLogger(BarangKeluar.class.getName()).log(Level.SEVERE, null, ex);
        }
}//GEN-LAST:event_jTextFieldPencarianActionPerformed

    private void jTextFieldPencarianFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextFieldPencarianFocusGained
        jTextFieldPencarian.setText("");
    }//GEN-LAST:event_jTextFieldPencarianFocusGained

    private void jTableBarangMasukMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTableBarangMasukMouseEntered
        // TODO add your handling code here:
    }//GEN-LAST:event_jTableBarangMasukMouseEntered

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonBatal;
    private javax.swing.JButton jButtonHapus;
    private javax.swing.JButton jButtonSimpan;
    private javax.swing.JButton jButtonTambah;
    private javax.swing.JButton jButtonUbah;
    private javax.swing.JComboBox jComboBoxJenisPencarian;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable jTableBarangMasuk;
    private javax.swing.JTextField jTextFieldDiterimaDari;
    private javax.swing.JTextField jTextFieldDiterimaOleh;
    private javax.swing.JTextField jTextFieldJumlah;
    private javax.swing.JTextField jTextFieldKeterangan;
    private javax.swing.JTextField jTextFieldKodeBarang;
    private javax.swing.JTextField jTextFieldPencarian;
    private javax.swing.JTextField jTextFieldTanggalMasuk;
    // End of variables declaration//GEN-END:variables
}
